package com.zerous.framework;

import java.math.*;

public class Vector2
{
	public BigDecimal x, y;
	public Vector2()
	{
		this.x = new BigDecimal(0);
		this.y = new BigDecimal(0);
	}
	
	public Vector2(BigDecimal x, BigDecimal y)
	{
		this.x = x;
		this.y = y;
	}
	
	public Vector2(Vector2 o)
	{
		this.x = new BigDecimal(o.x.floatValue());
		this.y = new BigDecimal(o.y.floatValue());
	}
	
	public Vector2(double x, double y)
	{
		this.x = new BigDecimal(x);
		this.y = new BigDecimal(y);
	}

	@Override
	public String toString()
	{
		// TODO: Implement this method
		return "(" + x.intValue() + ", " + y.intValue() + ")";
	}
	
	public void clear()
	{
		x = BigDecimal.ZERO;
		y = BigDecimal.ZERO;
	}
	
	public Vector2 filp(char x_or_y)
	{
		if(x_or_y == 'x')
		{
			x = BigDecimal.valueOf(-x.floatValue());
		}
		else if(x_or_y == 'y')
		{
			y = BigDecimal.valueOf(-y.floatValue());
		}
		return this;
	}
	
	public void setX(double x)
	{
		this.x = BigDecimal.valueOf(x);
	}
	
	public void setY(double y)
	{
		this.y = BigDecimal.valueOf(y);
	}
	
	
	public void set(double x, double y)
	{
		this.x = BigDecimal.valueOf(x);
		this.y = BigDecimal.valueOf(y);
	}
	
	public float getX()
	{
		return x.floatValue();
	}
	
	public float getY()
	{
		return y.floatValue();
	}
	
	public Vector2 add(Vector2 o)
	{
		return add(o.x, o.y);
	}
	
	public Vector2 add(BigDecimal ox, BigDecimal oy)
	{
		x = x.add(ox);
		y = y.add(oy);
		return this;
	}
	
	public Vector2 mul(Vector2 o)
	{
		return mul(o.x, o.y);
	}
	
	public Vector2 mul(BigDecimal ox, BigDecimal oy)
	{
		x = x.multiply(ox);
		y = y.multiply(oy);
		return this;
	}
	
	public Vector2 copy()
	{
		return new Vector2(this);
	}
	
	public Point toPoint()
	{
		return new Point(x.intValue(), y.intValue());
	}
}
